extends Control

var credits = [
    "PROGRAMMING\nJason Ko MacDuffie",
    "GRAPHICS\nJason Ko MacDuffie",
    "MUSIC\nJason Ko MacDuffie",
    "SOUND EFFECTS\nJason Ko MacDuffie",
    "TESTING\nCollette Manning",
    "GODOT ENGINE\nVarious contributors",
    "DROID FONTS\nGoogle Corp.",
    "SPECIAL THANKS\nYou, the player"
]

var counter = 0

func _ready():
    get_node("music").set_stream(load("res://Music/credits.ogg"))
    get_node("music").play()
    get_node("music").set_loop(true)
    set_process(true)

func _process(delta):
    if (Input.is_action_pressed("ui_accept")):
        change_scenes("res://Scenes/main_menu.xscn")

func next_credit():
    if (counter < credits.size()):
        get_node("text").set_text(credits[counter])
        counter += 1
    else:
        change_scenes("res://Scenes/main_menu.xscn")


func change_scenes(next_scene):
#    remove_and_delete_child(get_node("music"))
    get_node("/root/global").goto_scene(next_scene)
    get_node("/root/global").current_scene.get_node("button_credits").grab_focus()
